<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<%@ page import="co.gov.medellin.ssti.sub.model.vo.AtributoVO"%>

<script type="text/javascript"
	src="<%= request.getContextPath() + "/js/calendar6.js" %>"></script>
<script type="text/javascript"
	src="<%= request.getContextPath() + "/js/popUP.js" %>"></script>

<%@ page contentType="text/html;charset=utf-8"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>M&oacute;dulo de Secretarias</title>
<link href="../../css/jdeveloper.css" rel="stylesheet" media="screen" />
<link href="<%= request.getContextPath() + "/css/bloques.css" %>"
	rel="stylesheet" type="text/css">

<script type="text/javascript"> 

       function habilita(){
          if(document.frmsecretarias.subarea.value == "S")
          {
            document.frmsecretarias.code.disabled = false; 
          }else
          {
            document.frmsecretarias.code.disabled = true;
          }
       }
       
       function validardatos(){
        if(document.frmsecretarias.nombrearea.value != "")
        {
          if(document.frmsecretarias.subarea.value == "S")
          {
            if(document.frmsecretarias.code.value != "")
            {
              document.frmsecretarias.opcion.value='2';
              document.frmsecretarias.submit();
            }else
            {
              alert("Por favor seleccione la secretaría a la que pertenece.");
            }
          }else
          {
            document.frmsecretarias.opcion.value='2';
            document.frmsecretarias.submit();
          }
        }else
        {
          alert("Por favor ingrese el nombre de la secretaría.");
        }
      }
      
      function enviar(locacion1)
      {
        document.frmsecretarias.opcion.value='1';
        document.frmsecretarias.action=locacion1;
        document.frmsecretarias.submit();
      }
              
    </script>

</head>
<body>

	<P align="center" class="titulosenblanco">M&oacute;dulo de
		Secretarias</P>
	<form name="frmsecretarias"
		action="<%= request.getContextPath() + "/Areas/ModuloAreas.do" %>"
		method="get">
		<div align="center">
			<table
				style="width: 50%; height: 34; border: 0; padding: 2px; border-spacing: 1px;">

				<tr>
					<td>
						<DIV align="left" class="celdatabla">
							<STRONG>Nombre</STRONG>
						</DIV>
					</td>
					<td><input type="text" name="nombrearea" size="40"
						maxlength="99" class="form" /></td>
				</tr>
				<tr align="left">
					<td>
						<DIV align="left" class="celdatabla">
							<strong>Descripci&oacute;n</strong>
						</DIV>
					</td>
					<td>
						<DIV align="left">
							<input type="text" name="descripcionarea" size="40"
								maxlength="199" class="form" />
						</DIV>
					</td>
				</tr>
				<tr>
					<td align="left" class="celdatabla"><strong>Subsecretaria?</strong></td>
					<td align="left"><SELECT onchange="habilita()" NAME="subarea"
						Class="form">
							<OPTION value="N">NO</OPTION>
							<OPTION value="S">SI</OPTION>
					</SELECT></td>
				</tr>
				<tr>
					<td align="left" class="celdatabla"><strong>Escoja la
							Secretaria padre</strong></td>
					<td align="left"><logic:iterate id="areas"
							name="ListaAllAreas" length="1"
							type="co.gov.medellin.ssti.sub.model.vo.AreaVO">
							<html:select name="areas" property="code" styleClass="form">
								<html:options name="ListaAllAreas" labelName="AreaPadre"
									labelProperty="nombre" property="code"
									collection="ListaAllAreas" />
							</html:select>
						</logic:iterate></td>
				</tr>
			</table>
		</div>
		<br />
		<div align="center">
			<%String Ruta = "'"+request.getContextPath() + "/Areas/ModuloAreas.do'";%>
			<input type="HIDDEN" name="opcion" /> <input type="BUTTON"
				value="Consultar" onclick="enviar(<%=Ruta%>)" /> <input
				type="BUTTON" value="Ingresar" onclick="validardatos()" />
		</div>
		<br />
		<div align="center">
			<table style="border: 0; padding: 2px; border-spacing: 3px;">
				<tr>
					<td>
						<div align="center">
							<logic:present scope="request" name="ListaAreas">
								<display:table name="requestScope.ListaAreas" id="listArea"
									pagesize="20"
									requestURI='<%= request.getContextPath() + "/Areas/ModuloAreas.do" %>'
									style="width:100%" class="bordesTable">
									<display:column headerClass="headerTable" property="nombre"
										title="NOMBRE" class="Numero" sortable="true">
									</display:column>
									<display:column headerClass="headerTable"
										property="descripcion" title="DESCRIPCION" class="Numero"
										sortable="true">
									</display:column>
									<display:column headerClass="headerTable"
										title="SUBSECRETARIAS" class="Numero">
										<DIV align="center">
											<html:link paramId="code" paramName="listArea"
												paramProperty="code" page="/Areas/SubAreas.do">
												<img border="0"
													src="<%=request.getContextPath() + "/images/ver.gif"%>" />
											</html:link>
										</DIV>
									</display:column>
									<display:column headerClass="headerTable" title="MODIFICAR"
										class="Numero">
										<DIV align="center">
											<html:link paramId="code" paramName="listArea"
												paramProperty="code" page="/Areas/ModificationAreas.do">
												<img border="0"
													src="<%=request.getContextPath() + "/images/modificar.gif"%>" />
											</html:link>
										</DIV>
									</display:column>
								</display:table>
							</logic:present>

							<logic:notPresent scope="request" name="ListaAreas">
								<DIV align="center">
									<strong>La secretaria no existe</strong>
								</DIV>
								<BR />
							</logic:notPresent>

						</div>
					</td>
				</tr>
			</table>
		</div>

	</form>
</body>
</html>
